import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'package:get/get.dart';
import 'package:yi_shop/utils/colors.dart';
import 'package:yi_shop/utils/styles.dart';
import 'package:yi_shop/utils/tools.dart';

class CommunityPublishController extends GetxController {
  RxBool isDefault = false.obs;
}

class CommunityPublishPage extends GetView<CommunityPublishController> {
  const CommunityPublishPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: ToolsUtils.builderLeading(),
        title: Text(
          '发表评论',
          style: StylesUtils.customTextStyle(
              fontSize: StylesUtils.fontSize18, fontWeight: FontWeight.w700),
        ),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              padding: const EdgeInsets.only(top: 25, bottom: 15),
              alignment: Alignment.center,
              child: Container(
                padding: const EdgeInsets.all(10),
                width: 340,
                decoration: BoxDecoration(
                    border: Border.all(
                        color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorCccc))),
                child: TextField(
                  keyboardType: TextInputType.text,
                  cursorHeight: 15,
                  cursorWidth: 3,
                  cursorColor: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                  cursorRadius: const Radius.circular(2),
                  cursorOpacityAnimates: false,
                  maxLines: 10,
                  maxLength: 100,
                  minLines: 5,
                  style: StylesUtils.customTextStyle(color: ColorsUtils.color3333),
                  decoration: InputDecoration(
                      hintText: '',
                      hintStyle: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999, fontSize: StylesUtils.fontSize13),
                      border: InputBorder.none,
                      focusedBorder: InputBorder.none),
                  buildCounter: (context,
                      {required int currentLength, int? maxLength, required bool isFocused}) {
                    return Text(
                      '$currentLength/$maxLength',
                      style: StylesUtils.customTextStyle(
                        color: ColorsUtils.color9999,
                      ),
                    );
                  },
                  onChanged: (String value) {},
                ),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: 10),
              alignment: Alignment.center,
              child: SizedBox(
                width: 340,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '努力拼搏的80后',
                      style: StylesUtils.customTextStyle(color: ColorsUtils.color3333),
                    ),
                    Wrap(
                      spacing: 10,
                      crossAxisAlignment: WrapCrossAlignment.center,
                      alignment: WrapAlignment.end,
                      children: [
                        Text(
                          '匿名评论',
                          style: StylesUtils.customTextStyle(
                            color: ColorsUtils.color9999,
                          ),
                        ),
                        Obx(() => FlutterSwitch(
                              width: 48,
                              height: 24,
                              activeToggleColor: Colors.white,
                              activeColor:
                                  ColorsUtils.parseColorFromHexString(ColorsUtils.colorF26f),
                              inactiveColor:
                                  ColorsUtils.parseColorFromHexString(ColorsUtils.colorCccc),
                              toggleSize: 22,
                              padding: 2,
                              value: controller.isDefault.value,
                              onToggle: (bool value) {
                                controller.isDefault.value = value;
                              },
                            ))
                      ],
                    )
                  ],
                ),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: 10),
              alignment: Alignment.center,
              child: TextButton(
                  onPressed: () {},
                  style: ButtonStyle(
                      fixedSize: const MaterialStatePropertyAll(Size(340, 45)),
                      padding: const MaterialStatePropertyAll(EdgeInsets.zero),
                      alignment: Alignment.center,
                      backgroundColor: MaterialStatePropertyAll(
                          ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048)),
                      shape: MaterialStatePropertyAll(
                          RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.r)))),
                  child: Text(
                    '发表评论',
                    style: StylesUtils.customTextStyle(),
                  )),
            )
          ],
        ),
      ),
    );
  }
}
